<div class='head'>$lang.get('token.index.title')</div>

#parse('/widget/widget.message.html')

<div class='tabs'>
	<a href='/admin/token' class='selected'>$lang.get('a.token')</a>
</div>

<div class='search'>
	<form action='/admin/token' method='get' #if($currentpage>0) style='display:none' #end >
		<span><label><h3>$lang.get('label.name'):</h3><input type='text' name='name' value="$!name" placeholder="uid/sid/token"/></label></span>
		<button type='submit' class='btns1 icon icon-search'></button>
	</form>
	
	<div class='s1tab #if($currentpage>0) down #else up #end'>
		<div class='arrow'></div>
	</div>
</div>

#set($edit = $me.hasAccess('access.user.admin'))

<table id='user-table' class='tablesorter nospace' border="0" cellpadding="0" cellspacing="1">
	<thead>
		<tr>
			<th>$lang.get('user.uid')</th>
			<th>$lang.get('user.name')</th>
			<th>$lang.get('user.nickname')</th>
			<th>$lang.get('user.sid')</th>
			<th>$lang.get('user.token')</th>
			<th>$lang.get('user.expired')</th>
			<th>$lang.get('user.created')</th>
#if($edit)
			<th></th>
#end
		</tr>
	</thead>
	<tbody>
#foreach($f in $list)
	<tr>
		<td>$f.uid</td>
		<td>$!f.user_obj.name</td>
		<td>$!f.user_obj.nickname</td>
		<td>$!f.sid</td>
		<td>$!f.token</td>
		<td>$lang.format($f.expired, 'yy-MM-dd HH:mm:ss')</td>
		<td>$lang.format($f.created, 'yy-MM-dd HH:mm:ss')</td>
		#if($edit)
		<td>
			<a class='btn btn-danger btn-xs' href='javascript:;' onclick='_delete("$f.id", this);'>$lang.get('a.delete')</a>
		</td>
		#end
	</tr>
#end
	</tbody>
</table>

 #parse('/widget/goto.page.html')

<div class='btns'>
#if($edit)
	<a class='btn btn-danger' href='javascript:;' onclick='_clean()'>$lang.get('a.clean')</a>
#end
</div>

<script>
$('#user-table').tablesorter({headers:{7:{sorter:false}}});
function _clean() {
	if(confirm("$lang.get('title.are_u_sure_delete')")) {
		processing && processing.show();
		$.post('/admin/token/clean', {}, function(d){
			processing && processing.hide();
			reload();
		});
	}
}
function _delete(id, o) {
	if(confirm("$lang.get('title.are_u_sure_delete')")) {
		processing && processing.show();
		$.post('/admin/token/delete', {id:id}, function(d){
			processing && processing.hide();
			if(d.state == 200) {
				$(o).parent().parent().remove();
			} else if(d.message){
				$.error(d.message);
			}
		});
	}
}
</script>
